<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <!-- 自定义组件 -->
        <todo-list></todo-list>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        // 组件1，参数1：组件名称，参数2：组件配置
        Vue.component("todo-item", {
            // 定义组件参数
            props: {
                title: String,
                del: {
                    type: Boolean,
                    default: false // 定义默认值
                }
            },
            //组件html模版
            template:`
                <li>
                    <span v-if="!del">{{title}}</span>
                    <span v-else style="text-decoration: line-through">{{title}}</span>
                    <button v-show="!del">删除</button>
                </li>
            `,
            // 组件数据
            data: function() {
                return {}
            },
            // 组件方法
            methods:{

            },
        })
        // 组件2
        Vue.component("todo-list", {
            template:`
                <ul>
                    <todo-item  v-for="item in list" :title="item.title" :del="item.del"></todo-item>
                </ul>
            `,
            data: function(){
                return {
                    list:[
                        {
                            title: "课程1",
                            del: false
                        },
                        {
                            title: "课程2",
                            del: true
                        }
                    ]
                }
            }
        })
        var vm = new Vue({
            el: "#app",
            data: {}
        })
    </script>
</body>
</html>